<?php
class Logger_Data_Alllogs {
	
	private $database;
	
	public function __construct(){
		$this->database = new Core_Driver_MysqlImproved;
	}
	
	public function getData(){
		
		$article['template'] = "./logger/views/alllogs.php";
		$article['content'] .= "<h1>".LOGGER_ALL_LOGS."</h1>";
		$article['content'] .= '<p style="padding: 0 0 10px 0; text-align: center;">'.LOGGER_ALL_LOGS_MESSAGE.'</p>';
		$article['content'] .= '<table><tbody><tr><th>'.LOGGER_LOG_DATE.'</th><th>'.LOGGER_REQUEST_URL.'</th></tr>';
		$article['content'] .= $this->getDataToDatabase();
		$article['content'] .= '</tbody></table>';
		return $article;
 	
	}
 	
 	private function getDataToDatabase(){
 		$this->database->connect();
 		$this->database->prepare(
			"select * from logger order by actual_time desc limit 500;"
 		);
 		$this->database->query();
 		$content = "";
 		while($loggerData = $this->database->fetch('array')){
 			$content .= '<tr onclick="location=\''.SERVER_ROOT.'?logger&page='.$loggerData['id'].'\'"><td>'.$loggerData['actual_time'].'</td><td>'.$loggerData['request_url'].'</td></tr>';
 		}
 		return $content;
 	}
	
}